//
//  CityChooseViewController.m
//  Chirismus
//
//  Created by wangning on 15/11/2.
//  Copyright © 2015年 mohe. All rights reserved.
//

#import "CityChooseViewController.h"

@interface CityChooseViewController ()

@end

@implementation CityChooseViewController{
    NSArray *cityArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    cityArray = @[@"北京",@"上海",@"广州"];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return cityArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *identifier = [NSString stringWithFormat:@"identifier%ld",indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.textLabel.text = [cityArray objectAtIndex:indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *strCity = [cityArray objectAtIndex:indexPath.row];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"getCity" object:strCity];
    [[NSUserDefaults standardUserDefaults] setValue:strCity forKey:@"city"];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
